from functools import singledispatch


class ProcessHandler:
    @staticmethod
    @singledispatch
    def process_data(data) -> str:
        """默认处理方法"""
        raise NotImplementedError(f"不支持的数据类型: {type(data)}")

    @process_data.register(str)
    @staticmethod
    def _(data: str) -> str:
        """处理字符串类型"""
        return f"处理字符串: {data}"

    @process_data.register(int)
    @staticmethod
    def _(data: int) -> str:
        """处理整数类型"""
        return f"处理整数: {data}"

    @process_data.register(list)
    @staticmethod
    def _(data: list) -> str:
        """处理列表类型"""
        return f"处理列表: {len(data)} 个元素"


ProcessHandler.process_data("hello")

# 使用示例：
# ProcessHandler.process_data("hello")  # 输出: "处理字符串: hello"
# ProcessHandler.process_data(42)       # 输出: "处理整数: 42"
# ProcessHandler.process_data([1,2,3])  # 输出: "处理列表: 3 个元素"
